﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ATSBLL;

public partial class PIMTest_PIMTestSNCategory : System.Web.UI.Page
{ 
   private PIMTest Ptest;

    public PIMTest_PIMTestSNCategory()
    {
        Ptest = new PIMTest();
    }

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    /// <summary>
    /// 绑定
    /// </summary>
    public void BindPTests()
    {
        string productSN = tbSN.Text.Trim();
        GridView1.DataSource = Ptest.GetTestsbySN(productSN);
        GridView1.DataBind();
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            if (GridView1.Rows[i].Cells[8].Text == "Fail")
                GridView1.Rows[i].Cells[8].ForeColor = System.Drawing.Color.Red;
        }
    }

    /// <summary>
    /// 分页
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        BindPTests();
    } 

    /// <summary>
    /// 查询
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void buSelect_Click(object sender, EventArgs e)
    {
        BindPTests();
    }

    /// <summary>
    ///详情
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        string productSN = GridView1.SelectedDataKey["ProductSN"].ToString();
        Session["pIMRecordTime"] = Convert.ToDateTime(GridView1.SelectedDataKey["PIMRecordTime"]);
        //string pIMRecordTime = GridView1.SelectedDataKey["PIMRecordTime"].ToString();&pIMRecordTime=" + pIMRecordTime + "
        string productTypeID = GridView1.SelectedDataKey["ProductTypeID"].ToString();
        string userID = GridView1.SelectedDataKey["UserID"].ToString();
        string pIMENAID = GridView1.SelectedDataKey["PIM_ENAID"].ToString();
        string pIMPass = GridView1.SelectedDataKey["PIMPass"].ToString();
        Response.Redirect("../PIMTest/PIMTestDetails/ViewPIMTestItem.aspx?ProductSN=" + productSN + "&ProductTypeID=" + productTypeID + "&UserID=" + userID + "&PIM_ENAID=" + pIMENAID + "&PIMPass=" + pIMPass + "");
    }
}
